package com.xxy.services.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxy.pojo.Article;
import com.xxy.services.ArticleService;
import com.xxy.mapper.ArticleMapper;
import com.xxy.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Map;

/**
* @author Lenovo
* @description 针对表【article】的数据库操作Service实现
* @createDate 2024-01-28 17:15:38
*/
@Service
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article>
    implements ArticleService{

    @Autowired
    private ArticleMapper articleMapper;

    @Override
    public void add(Article article) {
        article.setCreate_time(LocalDateTime.now());
        article.setUpdate_time(LocalDateTime.now());

        Map<String,Object> map = ThreadLocalUtil.get();
        Integer userId = (Integer) map.get("id");
        article.setCreate_user(userId);
        articleMapper.add(article);

    }

    @Override
    public Article getArticleById(Integer id) {
        return null;
    }
}




